define([
     "dojo/_base/declare",
     "gistech/widgets/baseWidget/BaseWidget",
     "gistech/widgets/normalDialog/NormalDialog",
     "gistech/widgets/FileUpload/FileUpload",
     "dojo/text!./templates/template.html",
     "../../../app/UIManager",
     "dojo/_base/lang",
     "dojo/topic",
     "dojo/dom-style",
     "dojo/dom-construct",
     "dojo/on",
     "dojo/_base/connect",
     ],function(declare,BaseWidget,NormalDialog,FileUpload,template,UIManager,lang,Topic,style,domConstruct,on,eventconnect){
	    return declare([NormalDialog],{
	    	templateString:template,
	    	uuid:null,
	    	constructor:function(args){
	    		this.inherited(arguments);
	    	},
	    	postCreate:function(){
                this.inherited(arguments);
            },
            startup:function(){
                this.inherited(arguments);
                on(this.submit,"click",lang.hitch(this,this.pbMessage));
                on(this.reset,"click",lang.hitch(this,this.resetAttr));
                on(this.attchment,"click",lang.hitch(this,this.putFileUploadToPanel));
                this.uuid=uuid();
            },
            putFileUploadToPanel:function(){
            	if(dijit.byId("attchment")){
            		return false;
            	}else{
            		var fileUploadWidget=new FileUpload({id:"attchment","who":"Message","ownerId":this.uuid});
                	fileUploadWidget.setTitle("附件上传");
                	fileUploadWidget.startup();
            	}
            },
            pbMessage:function(){
            	var self=this;
            	debugger
            	if($("#title").val().trim(" ")!=""){
            		$.ajax({
            			type:"POST",
            			async:false,
            			url:"../client/backgroundManagement/MessageController/addNewMessage",
            			data:{id:self.uuid,title:$("#title").val(),content:$("#text-content").val(),userId:ioc.map.userInfoData.USERID,userName:ioc.map.userInfoData.DISPLAYNAME},
            			dataType:"json",
            			success:function(res){
            				debugger
            				layer.msg("发布成功",{icon:1});
            			    self.closeDialog();},
            			error:function(){
            				layer.msg("发布失败",{icon:2});}})
            	}else{
            		layer.msg("内容不规范",{icon:2});}
            },
            resetAttr:function(){
            	$("#title").val("");
            	$("#text-content").val("");
            },
            closeDialog:function(){
            	Topic.publish("RefreshMessageBox","refresh");
    			this.inherited(arguments);
    			this.destroy();
    		},
    		
	    })
     })